home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 August
/
Ahoy_Magazine_85-08_1985_Double_L.d64
/
birthday sim
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
41 lines
0 rem << rr20-3 >>
1 print"[147]":poke53280,0:poke53281,6:poke646,1
2 rem -- birthday simulator --
3 rem rupert report #20
4 rem
10 rem - simulate groups of people with
11 rem randomly chosen birthdays.
12 rem each group contains 'nump'
13 rem people. bday(x) is the
14 rem birthday (1-366) of the xth
15 rem person. ct(x) is the count of
16 rem how many people in the group
17 rem have day x as their birthday.
18 rem success=1 if two people in
19 rem one group have the same
20 rem birthday.
21 rem
30 nump=24 :rem << change this
40 dim bday(nump),ct(366)
50 group=1
60 success=0
65 rem - reset count of used birthdays
70 for persn=1 to nump
80 ct(bday(persn))=0 : next
85 rem - choose each person's birthday
90 for persn=1 to nump
100 day=int(366*rnd(0))+1
110 bday(persn)=day
120 ct(day)=ct(day)+1
130 next persn
135 rem - check for duplicates
140 for persn=1 to nump
150 if ct(bday(persn))<2 then 180
160 success=1
170 persn=nump
180 next persn
190 if success=1 then ttl=ttl+1
200 print group"groups ";
210 print ttl*100/group"% success"
220 group=group+1 : goto 60